using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

using EMan.Common.EnterpriseStructure;
using EMan.Interface.EnterpriseStructure;

using TrueCode.Core.Aspects;

namespace EMan.BL.EnterpriseStructure
{
  public class DepartmentNode : StructureTreeNode< Department >, IDepartmentNode
  {
    private readonly ObservableCollection< IStructureTreeNode > _children = new ObservableCollection< IStructureTreeNode >();

    private readonly List< EmployeeNode > _employeeNodes = new List< EmployeeNode >();
    
    public DepartmentNode( [NotNull] Department department, bool isNew ) : base( department, isNew )
    {
      if( department == null ) throw new ArgumentNullException( "department" );
    }

    public List< EmployeeNode > EmployeeNodes
    {
      get { return _employeeNodes; }
    }

    public void Add( Employee employee, bool isNew )
    {
      var employeeNode = new EmployeeNode( employee, isNew );
      _employeeNodes.Add( employeeNode );
      _children.Add( employeeNode );
    }

    public string Title
    {
      get { return Current.Title; }
    }

    public IEnumerable< IStructureTreeNode > Children
    {
      get { return _children; }
    }
  }
}